package com.stdspringboot.config;

import com.stdspringboot.vo.JsonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    //可以处理所有异常
    @ExceptionHandler(Exception.class)
    public JsonResult handleException(Exception e){//当controller抛出的异常对象，就传给该方法的形参
        e.printStackTrace();

        JsonResult jr=JsonResult.serverError("服务器发生错误，请联系管理员！");
        return jr;
    }
}
